home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-04 | 1.7 KB | 74 lines | [TEXT/PJMM] |
- unit MyScan;
-
- interface
-
- function ScanDirectory (fs: FSSpec; doit: procPtr): OSErr;
- { function Doit(var fs:FSSpec; folder:boolean; path:str255; var pb:CInfoPBRec):boolean }
- { for folders, return true to scan contents }
- { for files return true if you delete the file - other changes to the file system would be bad... }
-
- implementation
-
- uses
- MyFileSystemUtils;
-
- function CallProc (var fs: FSSpec; folder: boolean; path: str255; var pb: CInfoPBRec; p: ptr): boolean;
- inline
- $205F, $4E90;
-
- function ScanDirectory (fs: FSSpec; doit: procPtr): OSErr;
- var
- pb: CInfoPBRec;
- ret, folder: boolean;
- path: str255;
- procedure Scan (dirID: longInt);
- var
- index, len: integer;
- oe: OSErr;
- begin
- index := 1;
- repeat
- with pb do begin
- oe := MyGetCatInfo(fs.vRefNum, dirID, fs.name, index, pb);
- index := index + 1;
- if oe = noErr then begin
- fs.parID := dirID;
- folder := BAND(pb.ioFlAttrib, $10) <> 0;
- ret := CallProc(fs, folder, path, pb, doit);
- if folder and ret then begin
- len := length(path);
- path := concat(path, fs.name, ':');
- Scan(pb.ioDirID);
- path[0] := chr(len);
- end
- else if not folder and ret then begin
- index := index - 1;
- end;
- end;
- end;
- until oe <> noErr;
- end;
- var
- err: OSErr;
- dummy: boolean;
- begin
- path := ':';
- if fs.name <> '' then begin
- err := MyGetCatInfo(fs.vRefNum, fs.parID, fs.name, 0, pb);
- if err = noErr then begin
- if BAND(pb.ioFlAttrib, $10) <> 0 then begin
- Scan(pb.ioDirID);
- end
- else begin
- dummy := CallProc(fs, false, path, pb, doit);
- end;
- end;
- end
- else begin
- Scan(fs.parID);
- err := noErr;
- end;
- ScanDirectory := err;
- end;
-
- end.